const towxImg = require('../../../utils/towxImg');

const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
// packageIndex/pages/user/user.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    avatarUrl: defaultAvatarUrl,
    article: ''
  },

  onChooseAvatar(e) {
    const { avatarUrl } = e.detail
    this.setData({
      avatarUrl,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let code = '```\n<view class="user-container my-page">\n  <view class="notice">点击获取微信图像昵称</view>\n  <view class="main">\n    <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">\n      <image class="avatar" src="{{avatarUrl}}" mode="widthFix"></image>\n    </button>\n    <input type="nickname" class="weui-input" placeholder="请输入昵称" />\n  </view>\n</view>\n```\n\n```\nconst defaultAvatarUrl = ";\nhttps://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";\n// packageA/pages/user/user.js\nPage({\n  /**\n   * 页面的初始数据\n   */\n  data: {\n    avatarUrl: defaultAvatarUrl,\n  },\n  onChooseAvatar(e) {\n    const { avatarUrl } = e.detail\n    this.setData({\n      avatarUrl,\n    })\n  },\n})\n```\n';

    let article = towxImg.dealWithRichText(code);
    this.setData({ article });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})